/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.almori.hr.timetracker;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
        
/**
 *
 * @author Gcastillo
 */

public class TestBean {
    private static TimeTrackerDAO dao = new TimeTrackerDAO();
    private List<Department> departments;
    private Department selectedDepartment;
    private String departmentId;
    private String departmentCode;
    private String departmentInitials;
    private String departmentName;
    
    public TestBean() throws Exception{
    }

    public List<Department> getDepartments() {
        return departments;
    }

    public void setDepartments(List<Department> departments) {
        this.departments = departments;
    }

    public Department getSelectedDepartment() {
        return selectedDepartment;
    }

    public void setSelectedDepartment(Department selectedDepartment) {
        this.selectedDepartment = selectedDepartment;
    }

    public String getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }
    
    public void findDepartments() throws Exception {
        departments = dao.findDepartments(departmentCode, departmentInitials, departmentName);
    }
    
    public void reset(){
        departmentId = null;
        departmentCode = null;
        departmentInitials = null;
        departmentName = null;
        departments = null;
    }
    
    public void save() throws Exception{
        selectedDepartment.setCode(departmentCode);
        selectedDepartment.setInitials(departmentInitials);
        selectedDepartment.setDescription(departmentName);
        dao.saveDeparment(selectedDepartment);
    }

    public String getDepartmentCode() {
        return departmentCode;
    }

    public void setDepartmentCode(String departmentCode) {
        this.departmentCode = departmentCode;
    }

    public String getDepartmentInitials() {
        return departmentInitials;
    }

    public void setDepartmentInitials(String departmentInitials) {
        this.departmentInitials = departmentInitials;
    }
    
    public void addDepartment(){
        selectedDepartment = new Department();
    }
}
